/*
 * @Author: your name
 * @Date: 2021-12-17 15:26:00
 * @LastEditTime: 2022-05-18 16:31:38
 * @LastEditors: 陈宇 975155172@qq.com
 * @Description: 定义数据库的参数和数据类型
 * @FilePath: \blog-api\src\entities\user.entity.ts
 */

import { Column, Entity, PrimaryGeneratedColumn, BaseEntity, ManyToMany } from 'typeorm';
import { Abstract } from './../../abstract/entities/abstract.entity';

@Entity('tags')
export class Tags extends BaseEntity {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({type:'varchar', name: 'tag_name', comment: '标签名称', length: 10})
  tag_name: string;

  @Column({type:'varchar', name: 'describe', comment: '描述', nullable: false})
  describe: string;

  @ManyToMany(() => Abstract, abstract => abstract.id)
  abstract: Abstract[];

  @Column({
    name: 'create_time',
    type: 'timestamp',
    comment: '创建时间',
    default: () => 'CURRENT_TIMESTAMP',
  })
  create_time: Date;

  @Column({
      name: 'update_time',
      type: 'timestamp',
      comment: '更新时间',
      default: () => 'CURRENT_TIMESTAMP',
      onUpdate: 'CURRENT_TIMESTAMP',
  })
  update_time: Date;
}